package org.bright.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.bright.entity.User;
import org.bright.mapper.UserMapper;
import org.bright.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public List<User> getUsers() {
        String name = "";
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
//        如果name为空的话
        if(StringUtils.isNotEmpty(name)){
            queryWrapper.like("name","瓦");
            queryWrapper.or();
        }
        queryWrapper.eq("age",9);
        List<User> users = userMapper.selectList(queryWrapper);
        return users;
    }
}
